package top.kaoshanji.p1ch03a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * 代码清单-p1ch03a-65页a：表示人的类
 * author kaoshanji
 * ^_^
 * create time 2025/2/17 11:23
 */
public class Person {

    private static final Logger logger = LogManager.getLogger(Person.class);

    public static void main(String[] args) {

        logger.info("...代码清单-p1ch03a-65页a：表示人的类...");

        Person laoma = new Person("老ma");
        Person xiaoma = new Person("小ma");

        xiaoma.setFather(laoma); // 小ma 的父亲是 老ma
        laoma.setChildren(new Person[]{xiaoma}); // 老ma 的孩子是 小ma

        System.out.println(xiaoma.getFather().getName());
    }

    // 姓名
    private String name;

    // 父亲
    private Person father;

    // 母亲
    private Person mother;

    // 孩子数组
    private Person[] children;

    public Person(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Person getFather() {
        return father;
    }

    public void setFather(Person father) {
        this.father = father;
    }

    public Person getMother() {
        return mother;
    }

    public void setMother(Person mother) {
        this.mother = mother;
    }

    public Person[] getChildren() {
        return children;
    }

    public void setChildren(Person[] children) {
        this.children = children;
    }
}
